Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Create an abstraction layer for the database #407

Draft
wants to merge 38 commits into
base: master
Choose a base branch
from

Conversation

christianlupus
Copy link
Collaborator

@christianlupus christianlupus commented Nov 22, 2020

To allow for simpler development and future implemntation, this PR provides an internal API to the database.

It is related to #301.

Currently this PR is under development and should be considered Work in Progress. Suggestions and enhancements are welcome.

  • creating valid architecture
  • implemented features
  • test code
  • document interface
  • write unit test files

@christianlupus christianlupus self-assigned this Nov 22, 2020
@codecov
Copy link

codecov bot commented Nov 22, 2020

Codecov Report

Merging #407 (8e731e3) into master (f717e11) will decrease coverage by 0.24%.
The diff coverage is 0.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##             master    #407      +/-   ##
===========================================
- Coverage      0.87%   0.62%   -0.25%     
- Complexity      436     600     +164     
===========================================
  Files            14      30      +16     
  Lines          1375    1914     +539     
===========================================
  Hits             12      12              
- Misses         1363    1902     +539     
Flag Coverage Δ Complexity Δ
integration 0.00% <0.00%> (ø) 0.00 <199.00> (ø)
unittests 0.62% <0.00%> (-0.25%) 0.00 <199.00> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ Complexity Δ
lib/Db/AbstractDbWrapper.php 0.00% <0.00%> (ø) 8.00 <8.00> (?)
lib/Db/CategoryDbWrapper.php 0.00% <0.00%> (ø) 8.00 <8.00> (?)
lib/Db/CategoryMappingDbWrapper.php 0.00% <0.00%> (ø) 11.00 <11.00> (?)
lib/Db/DbWrapperServiceLocator.php 0.00% <0.00%> (ø) 6.00 <6.00> (?)
lib/Db/KeywordDbWrapper.php 0.00% <0.00%> (ø) 8.00 <8.00> (?)
lib/Db/KeywordMappingDbWrapper.php 0.00% <0.00%> (ø) 11.00 <11.00> (?)
lib/Db/RecipeDbWrapper.php 0.00% <0.00%> (ø) 31.00 <31.00> (?)
lib/Entity/RecipeJSONEntity.php 0.00% <0.00%> (ø) 26.00 <26.00> (?)
lib/Entity/impl/AbstractEntity.php 0.00% <0.00%> (ø) 7.00 <7.00> (?)
lib/Entity/impl/CategoryEntityImpl.php 0.00% <0.00%> (ø) 11.00 <11.00> (?)
... and 31 more

@christianlupus christianlupus added the Backend Issue or PR related to the backend code label Nov 23, 2020
* @param CategoryEntity $category The entity to store
*/
public function store(CategoryEntity $category): void {
// We do not need to store anything here. The categories are just virtually generated.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about creating categories as actual objects that can have, e.g., a description or other metadata? 😇

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simply put: No. 😁

The current DB schema has only a category name stored in a mapping type table. I kept with that for now. See also #300.

I was planning to proceed as follows:

  1. Create the entities and a DB abstraction layer parallel to the current main work.
  2. Deprecate major parts of the current RecipeDbService and refactor the DbCacheService that use direct DB operations.
  3. Migrate and refactor any current usage of any of these methods in the codebase
  4. Migrate any pending PRs to the new system
  5. Remove the direct DB access

After the DB access has been encapsulated as described here, we can add further setter/getter and fields in the DB without affecting the functionality of other parts.

Signed-off-by: Christian Wolf <[email protected]>
Signed-off-by: Christian Wolf <[email protected]>
Signed-off-by: Christian Wolf <[email protected]>
Signed-off-by: Christian Wolf <[email protected]>
Signed-off-by: Christian Wolf <[email protected]>
@MarcelRobitaille MarcelRobitaille changed the title WIP: Create an abstraction layer for the datanbase WIP: Create an abstraction layer for the database Jul 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backend Issue or PR related to the backend code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants